﻿<?xml version="1.0" encoding="UTF-8"?>
<!--=============================================================
    File: LeftNav.xslt                                                   
    Created by: sitecore\admin                                       
    Created: 7/26/2010 10:56:13 AM                                               
    Copyright notice at bottom of file
==============================================================-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sc="http://www.sitecore.net/sc" xmlns:dot="http://www.sitecore.net/dot" exclude-result-prefixes="dot sc">
  <!-- output directives -->
  <xsl:output method="html" indent="no" encoding="UTF-8" />
  <!-- parameters -->
  <xsl:param name="lang" select="'en'" />
  <xsl:param name="id" select="''" />
  <xsl:param name="sc_item" />
  <xsl:param name="sc_currentitem" />
  <!-- variables -->
  <!-- Uncomment one of the following lines if you need a "home" variable in you code -->
  <xsl:variable name="home" select="sc:item('/sitecore/content/EFI/',.)" />
  <!--<xsl:variable name="home" select="/*/item[@key='content']/item[@key='home']" />-->
  <!--<xsl:variable name="home" select="$sc_currentitem/ancestor-or-self::item[@template='Vutek Landing']" />-->
  <!-- entry point -->
  <xsl:template match="*">
    <xsl:apply-templates select="$sc_item" mode="main" />

  </xsl:template>
  <!--==============================================================-->
  <!-- main                                                         -->
  <!--==============================================================-->
  <xsl:template match="*" mode="main">
   
    <xsl:for-each select="$home/item">
      <xsl:if test="$sc_currentitem/ancestor-or-self::item/@id = @id">
        <xsl:choose>
          
          <xsl:when test="./@id='{14D06DBB-9D16-4A3D-8B7B-EDDC0C845CBA}'">
            <h2>
              <sc:text field="Navigation Title"/>
            </h2>
          </xsl:when>
          <xsl:otherwise>
            <h3>
              <sc:text field="Navigation Title"/>
            </h3>    
          </xsl:otherwise>
        </xsl:choose>
        

      </xsl:if>
    </xsl:for-each>

    <xsl:call-template name="renderLeftNav">
      <xsl:with-param name="root" select="$home"/>
      <xsl:with-param name="level" select="0"></xsl:with-param>
      <xsl:with-param name="items" select="$home/item[sc:fld('Dont Show In Left Nav',.)='']"/>
    </xsl:call-template>
    <xsl:call-template name="showhideleftnav"></xsl:call-template>
    <script type="text/javascript">
      $(document).ready(function () {
      if ($('ul#nav > li').hasClass('delete')) {
      $('ul#nav > li.delete > a > span').hide();
      }
      if ($('ul.nav1 > li.p').hasClass('open')) {
      $('ul.nav1 > li').addClass('hideSublings');
      $('ul.nav1 > li.p.open').removeClass('hideSublings');
      }
      if ($('ul.nav2 > li.p').hasClass('open')) {
      $('ul.nav2 > li').addClass('hideSublings');
      $('ul.nav2 > li.p.open').removeClass('hideSublings');
      }
      if ($('ul.nav3 > li.p').hasClass('open')) {
      $('ul.nav3 > li').addClass('hideSublings');
      $('ul.nav3 > li.p.open').removeClass('hideSublings');
      }
      if ($('ul.nav4 > li.p').hasClass('open')) {
      $('ul.nav4 > li').addClass('hideSublings');
      $('ul.nav4 > li.p.open').removeClass('hideSublings');
      }
      if ($('ul.nav5 > li.p').hasClass('open')) {
      $('ul.nav5 > li').addClass('hideSublings');
      $('ul.nav5 > li.p.open').removeClass('hideSublings');
      }
      if ($('ul.nav6 > li.p').hasClass('open')) {
      $('ul.nav6 > li').addClass('hideSublings');
      $('ul.nav6 > li.p.open').removeClass('hideSublings');
      }
      $('.selected').removeClass('hideSublings');
      });
    </script>
  </xsl:template>
  <xsl:template name="showhideleftnav">
  </xsl:template>
  <xsl:template name="renderLeftNav">
    <xsl:param name="root"/>
    <xsl:param name="level"/>
    <xsl:param name="items"/>
    
    <xsl:if test="$items">
        <xsl:element name="ul">
          <xsl:choose>
            <xsl:when test="$level>0">
              <xsl:attribute name="class">nav<xsl:value-of select="$level"/>
            </xsl:attribute>
            </xsl:when>
            <xsl:otherwise>
              <xsl:attribute name="id">nav</xsl:attribute>
            </xsl:otherwise>
          </xsl:choose>
        <xsl:for-each select="$items">
          <xsl:variable name="subItems" select="item[sc:fld('Dont Show In Left Nav',.)='']"></xsl:variable>
          <xsl:element name="li">
            <xsl:if test="sc:fld('Dont Show In Left Nav',.) = '' and ./@template != 'folder'">
              <xsl:attribute name="class">
                <xsl:if test="./@id='{65A383C0-A320-438C-9E21-7339C9395C96}' or ./@id='{E6A7E9AC-C654-4459-8989-72F74160D187}'">delete </xsl:if>
                <xsl:if test="$subItems">hasChildren </xsl:if>p<sc:text field="Show All Siblings"/>
                <xsl:if test="@id = $sc_currentitem/@id "> open selected </xsl:if>
                <xsl:if test="@id = $sc_currentitem/ancestor::item/@id"> open leftSpacing </xsl:if>
                <xsl:if test="position() = last()"> leftSpacing </xsl:if>
                <!--Call Show Siblings-->
                <xsl:choose>
                  <xsl:when test="sc:fld('Show All Siblings',$sc_currentitem) = ''">
                    <xsl:if test="$sc_currentitem/preceding-sibling::item/@id = @id"> hideSublings </xsl:if>
                    <xsl:if test="$sc_currentitem/following-sibling::item/@id = @id"> hideSublings </xsl:if>
                  </xsl:when>
                  <xsl:otherwise>
                  </xsl:otherwise>
                </xsl:choose>
                <xsl:choose>
                  <xsl:when test="sc:fld('Show All Children',$sc_currentitem) = ''">
                    <xsl:if test="$sc_currentitem/child::item/@id = @id"> childrent_t</xsl:if>
                  </xsl:when>
                  <xsl:otherwise></xsl:otherwise>
                </xsl:choose>
              </xsl:attribute>
              <!-- Begin view text link-->
              <xsl:call-template name="view">
                <xsl:with-param name="level" select="$level"></xsl:with-param>
              </xsl:call-template>
              <!--End view Text link-->
            </xsl:if>
            <xsl:if test="@id = $sc_currentitem/ancestor-or-self::item/@id">
              <xsl:call-template name="renderLeftNav">
                <xsl:with-param name="root" select="."/>
                <xsl:with-param name="level" select="$level+1"/>
                <xsl:with-param name="items" select="$subItems"/>
              </xsl:call-template>
            </xsl:if>
          </xsl:element>
        </xsl:for-each>
        </xsl:element>
    </xsl:if>
  </xsl:template>

  <xsl:template name="view">
    <xsl:param name="level"/>
        <xsl:choose>
          <xsl:when test="sc:fld('Link to Different Page',.)!=''">
            <sc:link field="Link to Different Page">
              <span>
                <xsl:if test="$level>1">> </xsl:if>
                <xsl:choose>
                  <xsl:when test="sc:fld('Left Navigation Title',.)!=''">
                    <sc:text field="Left Navigation Title"/>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:choose>
                      <xsl:when test="sc:fld('Navigation Title',.)!=''">
                        <sc:text field="Navigation Title" />
                      </xsl:when>
                      <xsl:otherwise>
                        <xsl:choose>
                          <xsl:when test="sc:fld('Nav Title',.)!=''">
                            <sc:text field="Nav Title" />
                          </xsl:when>
                          <xsl:otherwise>
                            <xsl:choose>
                              <xsl:when test="sc:fld('NavTitle',.)!=''">
                                <sc:text field="NavTitle" />
                              </xsl:when>
                              <xsl:otherwise>
                                <xsl:value-of select="./@name" />
                              </xsl:otherwise>
                            </xsl:choose>
                          </xsl:otherwise>
                        </xsl:choose>
                      </xsl:otherwise>
                    </xsl:choose>
                  </xsl:otherwise>
                </xsl:choose>
              </span>
            </sc:link>
          </xsl:when>
          <xsl:otherwise>
            <sc:link>
              <span>
                <xsl:if test="$level>1">> </xsl:if>
                <xsl:choose>
                  <xsl:when test="sc:fld('Left Navigation Title',.)!=''">
                    <sc:text field="Left Navigation Title"/>
                  </xsl:when>
                  <xsl:otherwise>
                    <xsl:choose>
                      <xsl:when test="sc:fld('Navigation Title',.)!=''">
                        <sc:text field="Navigation Title" />
                      </xsl:when>
                      <xsl:otherwise>
                        <xsl:choose>
                          <xsl:when test="sc:fld('Nav Title',.)!=''">
                            <sc:text field="Nav Title" />
                          </xsl:when>
                          <xsl:otherwise>
                            <xsl:choose>
                              <xsl:when test="sc:fld('NavTitle',.)!=''">
                                <sc:text field="NavTitle" />
                              </xsl:when>
                              <xsl:otherwise>
                                <xsl:value-of select="./@name" />
                              </xsl:otherwise>
                            </xsl:choose>
                          </xsl:otherwise>
                        </xsl:choose>
                      </xsl:otherwise>
                    </xsl:choose>
                  </xsl:otherwise>
                </xsl:choose>
              </span>
            </sc:link>
          </xsl:otherwise>
        </xsl:choose>
  </xsl:template>

</xsl:stylesheet>
